//Enhanced User Name Dictionary Creator
//By: Ryan McDougall
//3-8-2011
//
// This program creates accurate user name dictionaries for use with brute force
// account auditing tools.
//

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>

using namespace std;

//Components that make up each user name. Schemas can be added
//or modified depending on the need.
struct schema
{
	string component1;
	string component2;
	int  numcomponent;
};

int main()
{
	//loop counter
	int count = 0;
	//combo size
    int size = 2596;
    //Line count
    int lcFile1 = 0;
    int lcFile2 = 0;
    
	//Vars for reading in components from files
	schema combo[size];

    //Select input files for schema
	ifstream inputFile1;
	ifstream inputFile2;
	ofstream o_file;

	inputFile1.open("wl1.txt");
	inputFile2.open("testcomp2.txt");
	
    
    //Line Counts
    string line1;
    while(!inputFile1.eof())
    {
        getline (inputFile1,line1);
        lcFile1++;
    }
    
    cout << lcFile1 - 1 << endl;
    
    string line2;
    while(!inputFile2.eof())
    {
        getline (inputFile2,line2);
        lcFile2++;
    }
    
    cout << lcFile2 - 1 << endl;
    
    o_file.open("output.txt");
	
	//First iteration
	inputFile1 >> combo[count].component1;
    cout << combo[count].component1 << endl;
	
    inputFile2 >> combo[count].component2;
    cout << combo[count].component2 << endl;
	
    cout << "Creating dictionary...	" << endl;
	
	//Loop to create all possibilities from input files.
	for (int i = 0; i < lcFile1 - 1; i++)
    {
      inputFile1 >> combo[count].component1;
      for(int j=0; j <= lcFile2 - 1; j++)
      {
        inputFile2 >> combo[j].component2;
        o_file << combo[count].component1 << combo[j].component2 << endl;
        //cout << combo[count].component1 << combo[j].component2 << endl;
          
      }
      count++;
    }
    

	inputFile1.close();
	inputFile2.close();
	o_file.close();
	
	cout << "Dictionary complete. Open the output.txt file to see results" << endl;

    //system("PAUSE");     //Uncomment for use in Windows OS

}